void ScanLine (ImSize, Dir, GlidLen, MinDif, NofHit, LineLen,
               NofSegs, Line, Image, Segs)
int     ImSize, Dir, GlidLen, MinDif, NofHit, LineLen, *NofSegs;
LinTyp  *Line;
BYTE    **Image;
SegTyp  *Segs;
{
   int  i,j, r,c, rc,cc, r0,c0,r1,c1, n, Start, Stop;

   Start = -1;
   for (i=0; i<LineLen-GlidLen; i++) {
      n = 0;
      for (j=0; j<GlidLen; j++) {
         r = Line[i+j].r;
         c = Line[i+j].c;
         NeighInds (ImSize, Dir, r,c, &r0,&c0,&r1,&c1);
         if (abs (Image [r0][c0] - Image [r1][c1]) > MinDif)  n++;
      }
      if (n>=NofHit) {
         if (Start<0)  Start = i;
      }else{
         if (Start>=0) {
            Stop = i+GlidLen-1;
            Segs[*NofSegs].r0  = Line[Start].r;
            Segs[*NofSegs].c0  = Line[Start].c;
            Segs[*NofSegs].r1  = Line[Stop].r;
            Segs[*NofSegs].c1  = Line[Stop].c;
            ++*NofSegs;
            Start = -1;
}  }  }  }
